<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="ishopplace" uri="ishopplace.view.validator" %>

<f:subview id="editAccount">
<h:form id="editAccountForm">
<h:panelGrid columns="1" styleClass="standard">
  <h:outputText value="Your Account Information" styleClass="title"/>
  <h:outputText value="Contact Information" styleClass="subTitle"/>
  <h:panelGrid columns="2" columnClasses="highLight,,">
    <h:outputText value="First Name"/>
    <h:panelGroup>
      <h:inputText value="#{accountBean.account.firstName}" id="firstName" size="30" required="true"/>
      <h:message styleClass="errorMessage" for="firstName"/>
    </h:panelGroup>
    <h:outputText value="Last Name"/>
    <h:panelGroup>
      <h:inputText value="#{accountBean.account.lastName}" id="lastName" size="30" required="true"/>
      <h:message styleClass="errorMessage" for="lastName"/>
    </h:panelGroup>
    <h:outputText value="Street Address"/>
    <h:panelGroup>
      <h:inputText value="#{accountBean.account.address1}" id="address1" size="55" required="true"/>
      <h:message styleClass="errorMessage" for="address1"/>
    </h:panelGroup>
    <h:outputText value=""/>
    <h:inputText value="#{accountBean.account.address2}" size="55"/>
    <h:outputText value="City"/>
    <h:panelGroup>    
      <h:inputText value="#{accountBean.account.city}" id="city" size="30" required="true"/>
      <h:message styleClass="errorMessage" for="city"/>
    </h:panelGroup>
    <h:outputText value="State/Provice"/>
    <h:selectOneMenu value="#{accountBean.account.state}">
      <f:selectItem itemValue="CA" itemLabel="California"/>
      <f:selectItem itemValue="NY" itemLabel="New York"/>
      <f:selectItem itemValue="TX" itemLabel="Texas"/>
    </h:selectOneMenu>
    <h:outputText value="Postal Code"/>
    <h:panelGroup>    
      <h:inputText value="#{accountBean.account.zip}" id="zip" size="12" required="true">
        <ishopplace:validateRegex pattern="^\d{5}(-\d{4})?$" errorMsg="Invalid postal code"/>
      </h:inputText> 
      <h:message styleClass="errorMessage" for="zip"/>
    </h:panelGroup>      
    <h:outputText value="Country"/>
    <h:selectOneMenu value="#{accountBean.account.country}">
      <f:selectItem itemValue="USA" itemLabel="United States"/>
      <f:selectItem itemValue="Canada" itemLabel="Canada"/>
      <f:selectItem itemValue="Japan" itemLabel="Japan"/>
      <f:selectItem itemValue="China" itemLabel="China"/>
    </h:selectOneMenu>    
    <h:outputText value="Telephone Number"/>
    <h:panelGroup>    
      <h:inputText value="#{accountBean.account.phone}" id="phone" size="12" required="true"/>  
      <h:message styleClass="errorMessage" for="phone"/>
    </h:panelGroup>      
    <h:outputText value="Email"/>
    <h:panelGroup>    
      <h:inputText value="#{accountBean.account.email}" id="email" size="30" required="true"> 
        <ishopplace:validateRegex 
        	pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$"
        	errorMsg="Invalid email address"/>
      </h:inputText>  
      <h:message styleClass="errorMessage" for="email"/>
    </h:panelGroup>      
  </h:panelGrid>
  <h:outputText value="Credit Card Information" styleClass="subTitle"/>
  <h:panelGrid columns="2" columnClasses="highLight,,">
    <h:outputText value="Card Number"/>
    <h:panelGroup>    
      <h:inputText value="#{accountBean.account.creditCard}" id="creditCard" size="30" required="true"/>
      <h:message styleClass="errorMessage" for="creditCard"/>
    </h:panelGroup>      
    <h:outputText value="Card Type"/>
    <h:selectOneMenu value="#{accountBean.account.cardType}">
      <f:selectItem itemValue="Java(TM) Card" itemLabel="Java(TM) Card"/>
      <f:selectItem itemValue="Duke Express" itemLabel="Duke Express"/>
      <f:selectItem itemValue="Meow Card" itemLabel="Meow Card"/>
    </h:selectOneMenu> 
    <h:outputText value="Card Expiry Date"/>
    <h:panelGroup>
      <h:outputText value="Month  "/>
      <h:selectOneMenu value="#{accountBean.expiryMonth}">
        <f:selectItem itemValue="01" itemLabel="01"/>
        <f:selectItem itemValue="02" itemLabel="02"/>
        <f:selectItem itemValue="03" itemLabel="03"/>
        <f:selectItem itemValue="04" itemLabel="04"/>
        <f:selectItem itemValue="05" itemLabel="05"/>
        <f:selectItem itemValue="06" itemLabel="06"/>
        <f:selectItem itemValue="07" itemLabel="07"/>
        <f:selectItem itemValue="08" itemLabel="08"/>
        <f:selectItem itemValue="09" itemLabel="09"/>
        <f:selectItem itemValue="10" itemLabel="10"/>
        <f:selectItem itemValue="11" itemLabel="11"/>
        <f:selectItem itemValue="12" itemLabel="12"/>
      </h:selectOneMenu> 
      <h:outputText value="  Year  "/>
      <h:selectOneMenu value="#{accountBean.expiryYear}">
        <f:selectItem itemValue="04" itemLabel="04"/>
        <f:selectItem itemValue="05" itemLabel="05"/>
        <f:selectItem itemValue="06" itemLabel="06"/>
        <f:selectItem itemValue="07" itemLabel="07"/>
      </h:selectOneMenu> 
    </h:panelGroup>
  </h:panelGrid>
  <h:outputText value="Profile Information" styleClass="subTitle"/>
  <h:panelGrid columns="2" columnClasses="highLight,,">
    <h:outputText value=""/>
    <h:panelGroup>
      <h:outputText value="I want iShopPlace to be in "/>
      <h:selectOneMenu value="#{accountBean.account.languagePreference}">
        <f:selectItem itemValue="English" itemLabel="English"/>
        <f:selectItem itemValue="Japanese" itemLabel="Japanese"/>
        <f:selectItem itemValue="Chinese" itemLabel="Chinese"/>
      </h:selectOneMenu> 
    </h:panelGroup>
    <h:outputText value=""/>
	<h:panelGroup>
      <h:outputText value="My favorite category is "/>
      <h:selectOneMenu value="#{accountBean.account.favoriteCategoryId}">
        <f:selectItem itemValue="BIRDS" itemLabel="Cats"/>
        <f:selectItem itemValue="DOGS" itemLabel="Dogs"/>
        <f:selectItem itemValue="FISH" itemLabel="Fish"/>
        <f:selectItem itemValue="REPTILES" itemLabel="Reptiles"/>
      </h:selectOneMenu> 
    </h:panelGroup>
    <h:selectBooleanCheckbox value="#{accountBean.account.listOption}"/>
    <h:outputText value="Yes, I want to enable the MyList feature. (MyList makes your favorite items and categories more prominent as you shop.)"/>
    <h:selectBooleanCheckbox value="#{accountBean.account.bannerOption}"/>
    <h:outputText value="Yes, I want to enable the pet tips banners. (Java Pet Store will display pet tips as you shop, which are based on your favorite items and categories.)"/>
  </h:panelGrid>
  <h:commandButton value="Update" action="#{accountBean.updateAction}"/>
</h:panelGrid>
</h:form>
</f:subview>